package edu.vital.energy.longevity.ch11.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class MailUtils {


    @Autowired
    private JavaMailSender javaMailSender;

    public void sendSimpleMail(String mailto,String Subject,String text)   {
        SimpleMailMessage message = new SimpleMailMessage();
        // 配置发送者邮箱
        message.setFrom("751965763@qq.com");
        // 配置接受者邮箱
        message.setTo(mailto);
        // 配置邮件主题
        message.setSubject(Subject);
        // 配置邮件内容
        message.setText(text);
        // 发送邮件
        javaMailSender.send(message);
    }
}

